package com.bit.catmoney;

import java.util.ArrayList;

import com.bit.catmoney.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class RankAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private int mLayout;
	private ArrayList<RankData> mItems;
	private Context mContext;

	public RankAdapter(Context context, int layout, ArrayList<RankData> arData) {
		mContext = context;
		mLayout = layout;
		mItems = arData;
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(mLayout, parent, false);
		}
		TextView tv = (TextView) convertView.findViewById(R.id.nickname);
		tv.setText(mItems.get(position).nickname);
		TextView tvDesc = (TextView) convertView.findViewById(R.id.score);
		tvDesc.setText(mItems.get(position).score);
		return convertView;
	}
}
